#ifndef RTSP_SERVICE_BSOCKETFILE_H
#define RTSP_SERVICE_BSOCKETFILE_H

#define BSOCKETFILE_RET_ERROR -1
#define BSOCKETFILE_RET_SUCCEED 0
#define BSOCKETFILE_RET_WAIT 1

//用于从文件中读取数据，加快读取速度.
typedef struct BSocketFile {
    int socket_id;              //TCP套接字
    unsigned int wbuf_len;      //发送数据长度
    unsigned int widx;          //当前发送数据长度
    unsigned char *wbuf;        //发送缓冲区

    unsigned int rdata_len;     //缓冲区数据长度
    unsigned int ridx;          //缓冲区读取引索
    unsigned int rbuf_len;      //缓冲区长度
    unsigned char *rbuf;        //缓冲区
} BSocketFile;

extern void BSocketFile_init(BSocketFile *file, unsigned char *buf, unsigned int buf_len, int sock_id);

extern int BSocketFile_read(BSocketFile *file, unsigned char *ch);

extern int BSocketFile_wirte(BSocketFile *file, unsigned char *data, unsigned data_len);

#endif //RTSP_SERVICE_BSOCKETFILE_H
